package njson

import "encoding/json"

func O(items... interface{}) map[string]interface{} {
	mp := make(map[string]interface{})
	max := len(items)
	for i := 0; i < max; i+=2 {
		if key, ok := items[i].(string); ok {
			mp[key] = items[i + 1]
		}
	}
	return mp
}

func A(items... interface{}) []interface{} {
	var ret []interface{}
	return append(ret, items...)
}

func SA(str string) []interface{} {
	var a []interface{}
	err := json.Unmarshal([]byte(str), &a)
	if err != nil {
		return nil
	}
	return a
}

func SO(str string) map[string]interface{} {
	var a map[string]interface{}
	err := json.Unmarshal([]byte(str), &a)
	if err != nil {
		return nil
	}
	return a
}